/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef PLELF_APPLICATION_HEADER32_H
#define PLELF_APPLICATION_HEADER32_H

#include <elf/plelfstddef.h>
#include <elf/plelfapplicationheaderenums.h>

namespace PLSDK {

/**
 * Elf application headers.
 */
class PLELFApplicationHeader32 : public PLELFApplicationHeaderEnums {
public:
	/**
	 * Constructor.
	 */
	inline PLELFApplicationHeader32() {}
	/**
	 * Get the header type.
	 *
	 * @return The type.
	 */
	inline PLELFApplicationHeader32::PType type();
	/**
	 * Get the flags of the application header.
	 *
	 * @return The flags.
	 */
	inline PLELFApplicationHeader32::PFlags flags();
	/**
	 * This member tells what kind of segment this array element describes or
	 * how to interpret the array element's information.
	 */
	Elf32_Word p_type;
	/**
	 * This member gives the offset from the beginning of the file at which the
	 * first byte of the segment resides.
	 */
	Elf32_Off  p_offset;
	/**
	 * This member gives the virtual address at which the first byte of the segment
	 * resides in memory.
	 */
	Elf32_Addr p_vaddr;
	/**
	 * On systems for which physical addressing is relevant, this member is
	 * reserved for the segment's physical address. Because System V ignores physical
	 * addressing for application programs, this member has unspecified contents for
	 * executable files and shared objects.
	 */
	Elf32_Addr p_paddr;
	/**
	 * This member gives the number of bytes in the file image of the segment; it may be zero.
	 */
	Elf32_Word p_filesz;
	/**
	 * This member gives the number of bytes in the memory image of the segment; it may be zero.
	 */
	Elf32_Word p_memsz;
	/**
	 * This member gives flags relevant to the segment.
	 */
	Elf32_Word p_flags;
	/**
	 * As ``Program Loading'' describes in this chapter of the processor supplement, loadable
	 * process segments must have congruent values for p_vaddr and p_offset, modulo the page size.
	 * This member gives the value to which the segments are aligned in memory and in the file.
	 * Values 0 and 1 mean no alignment is required. Otherwise, p_align should be a positive,
	 * integral power of 2, and p_vaddr should equal p_offset, modulo p_align.
	 */
	Elf32_Word p_align;
} __attribute__((packed));

PLELFApplicationHeader32::PType PLELFApplicationHeader32::type() {
	return (PLELFApplicationHeader32::PType)p_type;
}

PLELFApplicationHeader32::PFlags PLELFApplicationHeader32::flags() {
	return (PLELFApplicationHeader32::PFlags)p_flags;
}

}

#endif
